 $(document).ready(function() {

	

	$('.disposTypesSortable').sortable({

		items : 'div',

		axis: 'y',

		containment: 'parent',

		tolerance: 'pointer',

		stop: function(event,ui){ disposTypesSort(); }

	});

	

});

 

 function disposTypesSort() {

	a=document.getElementById('types');

	a.value='';

	$('.disposTypesSortable').find('.disposTypesSortableItem').each(function(){

		a.value+=$(this).find('.nom').html()+';'+$(this).find('.colorPicker').eq(0).css('background-color')+'|';

	});

	$.post('ajaxload.php', { page: 'modules/dispos/admin/ajax.php', action: 'disposTypes', types: a.value} );

}



function disposTypesSupprimer(h){

	$(h).closest(".disposTypesSortableItem").remove();

	disposTypesSort();

}



function disposTypesAjouter(){

	nom=$('#disposTypesAjouterNom').attr('value');

	couleur=$('#disposTypesAjouterColor').css('background-color');

	if(nom!=''){

		$('#disposTypesAjouterNom').attr('value','');

		$('#disposTypesAjouterColor').css('background-color','#FFFFFF');

		$('.disposTypesSortable').append("<div class='disposTypesSortableItem'><table cellspacing='0' cellpadding='1'><tr><td><span class='ui-icon ui-icon-arrowthick-2-n-s' style='float: left;'></span>&nbsp;<span class='nom' id='"+nom+"'>"+nom+"</span></td><td style='width: 17px; border-left: 1px solid #000000;'><div class='colorPicker' style=' background-color: "+couleur+";'></div></td><td style='width: 10px; border-width: 0px; border-left: 1px solid #000000;' onmouseover='$(this).addClass(\"ui-state-hover\");' onmouseout='$(this).removeClass(\"ui-state-hover\");' onclick='disposTypesSupprimer(this);'><span class='ui-icon ui-icon-circle-close tooltip' title='Supprimer ce type'></span></td></tr></table></div>");

		set_tooltip(".disposTypesSortableItem *[title].tooltip");

		disposTypesSort();

	}

}